﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Project.Ycm20250401.Service._20250408
{
    public class WeChatPayAdapter : IPaymentProvider
    {
        private readonly WeChatPayService _wechatPay;

        public WeChatPayAdapter(WeChatPayService wechatPay) => _wechatPay = wechatPay;

        public async Task<PaymentResult> PayAsync(decimal amount, string orderId, object metadata)
        {
            // 微信SDK需要不同的参数格式
            var request = new WeChatRequest(amount, orderId, "");
            var response = await _wechatPay.ExecutePaymentAsync(request);

            return new PaymentResult(
                response.TransactionId,
                orderId,
                amount,
                response.Currency,
                response.Timestamp
            );
        }
    }
}
